/**
 * @file window.h
 * @brief main program window
 * @date 2020-10-14
 */
#pragma once

#include <QWidget>
#include "lab.h"

class UpgradeView;
class ProductView;
class State;
class QGridLayout;
struct OptimumValues;

/**
 * @class MainWindow
 * @brief This class is main window for Cleant energy event
 * 
 * Contain information with all upgrades, resources and provide elements to control
 */
class MainWindow :  public QWidget {
    Q_OBJECT

    std::shared_ptr<State> playerData;
    QGridLayout * grid;

    UpgradeView * addUpgrade(UpgradeType type, int row,  int column);
    ProductView * addProduct(ProductType type, int row, int column);
    void updateViews();

public:
    /**
     * @brief Construct  MainWindow 
     * @param parent QWidget parent
     */
    explicit MainWindow(QWidget * parent);

public slots:
    /**
     * @brief change level of specified upgrade type
     * @param type upgrade type
     * @param level new level value
     */
    void setLevel(UpgradeType type, int level);

    /**
     * @brief Change auto control mode state
     * @param   mode    enable on true, disable on false
     */
    void setAutoControlMode( bool mode );

    /**
     * @brief change step size
     * @param step new step value
     */
    void setStep(int step);

    /**
     * @brief change tier
     * @param tier new tier value
     */
    void setTier(double tier);

    /**
     * @brief change playthrough
     * @param playthrough new playthrough value
     */
    void setPlaythrough( int playthrough );

    /**
     * @brief Change weight of specified product type
     * @param   type    product type
     * @param   weight  new product weight
     */
    void setProductWeight(ProductType type, double weight );

    /**
     * @brief Change value of specified product type
     * @param   type    product type
     * @param   value   new product weight
     */
    void setProductValue(ProductType type, double value );

    /**
     * @brief Change factor of specified type product
     * @param   type    product type
     * @param   factor  new factor value
     */
    void setProductFactor(ProductType type, double factor);

    /**
     * @brief Change settings to optimized
     * @param   optimum     optimized values
     */
    void setOptimum(const OptimumValues & optimum );

    /**
     * @brief Fast forwards skip time
     * @param seconds how many seconds to skip
     */
    void tick( int seconds );

    /**
     * @brief claim orb
     * @param   orbs    orb count
     */
    void claimOrb( int orbs );

signals:
    /**
     * @brief emmited on data changing
     * @param state new data
     */
    void updateData(const State & state);
};
